import request from "@/utils/request";

export const getCommunityList = () => {
    return request.get("/community/list");
}

export const getUserCommunityList = () => {
    return request.get("/community/user/list");
}

export const getCommunityInfo = (id: string) => {
    return request.get("/community/info", {
        params: {
            "id": id
        }
    });
}

export const uploadCommunityImage = (image: File) => {
    return request.post("/community/image/upload", {
        "image": image
    }, {
        headers: {
            "Content-Type": "multipart/form-data"
        },
        timeout: 60000
    })
}

export const createCommunity = (avatar: File, name: string, description: string, title: string) => {
    return request.post("/community/create", {
        "avatar": avatar,
        "name": name,
        "description": description,
        "title": title
    }, {
        headers: {
            "Content-Type": "multipart/form-data"
        },
        timeout: 60000
    });
}

export const getCommunityMember = (id: string) => {
    return request.get("/community/member/state", {
        params: {
            "id": id
        }
    })
}

export const checkWhetherToJoin = (id: string) => {
    return request.get("/community/member/check", {
        params: {
            "id": id
        }
    })
}

export const joinCommunity = (communityId: string, userId: string) => {
    return request.post("/community/member/join", {
        "communityId": communityId,
        "userId": userId
    })
}

export const leaveCommunity = (communityId: string, userId: string) => {
    return request.post("/community/member/leave", {
        "communityId": communityId,
        "userId": userId
    })
}

export const getCommunityTagList = (communityId: string) => {
    return request.get("/community/tag/list", {
        params: {
            "communityId": communityId
        }
    })
}

export const dissolveCommunity = (communityId: string) => {
    return request.post("/community/dissolve", {
        "id": communityId
    });
}

export * from './article';

export * from './comment';

export * from './type';